import React,{useEffect,useState} from 'react'

export default function List() {
    const [count, setcount] = useState([])
    const Switch = ()=>{
        setcount([])
        console.log(count)
        tihuan()
    }
    const tihuan = ()=>{
        console.log(count)
        setcount(count=>{count.push('1')})
        console.log(count)
    }
    useEffect(() => {
        Switch()
         // 这里便能够打印最新的state
    }, [])
    useEffect(() => {
        console.log(count, 'count');
    }, [count])
    return (
        <div>
            {count}
            <button onClick={Switch}>清除</button>
        </div>
    )
}
